#!/bin/bash

ARCH=amd64
#ARCH=arm64
#ARCH=nttr1
#ARCH=c600
#ARCH=mips32

dirpath=build-$ARCH

#CMAKE_FLAGS="-DOPENCV=ON"
#CMAKE_FLAGS+=" -DOPENGL=ON -DWITH_QT=ON"
#CMAKE_FLAGS+=" -DCODEC=ON"
#CMAKE_FLAGS+=" -DCMAUTOTEST=ON"
#CMAKE_FLAGS+=" -DWITH_DATABASE=ON"
#CMAKE_FLAGS+=" -DWITH_LIBCURL=ON"
#CMAKE_FLAGS+=" -DWITH_MQTT=ON"
#CMAKE_FLAGS+=" -DWITH_COAP=ON"
CMAKE_FLAGS+=" -DWITH_TUYA=ON"

if [ "$ARCH" = "c600" ]; then
	CMAKE_FLAGS+=" -DWITH_GCC_HIGH=OFF"
fi

[ ! -d $dirpath ] && mkdir $dirpath

cd $dirpath
cmake .. -DCMAKE_TOOLCHAIN_FILE=../tools/$ARCH.cmake \
	-DPLAT=$ARCH \
	$CMAKE_FLAGS -DLINUX=ON

	#-DCMAKE_MODULE_PATH=/opt/data/proj/src/nanopi/linuxsdk-friendlyelec/buildroot/output/rockchip_rk3399/staging \

if [ "$1" = "d" ]; then
make VERBOSE=yes
else
	make
fi
